﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using ProjectManagement.Domain.AutoMappings;
using ProjectManagement.Domain.Entities;
using NHibernate.Linq;

namespace ProjectManagement.Domain.Services
{
	public class CityService
	{
		private ISessionFactory factory = NHibernateHelper.CreateSessionFactory();
		public IEnumerable<City> QueryCityByProId(int id)
		{
			using (var session = factory.OpenSession())
			{
				return session.Query<City>()
					.Where(c=>c.Provience.ID==id)
					.ToList();
					
			}
		}
		public City GetCityById(int id)
		{
			var session = factory.OpenSession();
			return session.Query<City>()
				.Where(c => c.ID == id).First();
		}
	}
}
